//
//  MainTabBarViewController.m
//  Hipay_uuTianfu
//
//  Created by Mac on 16/4/28.
//  Copyright © 2016年 展鸿科技. All rights reserved.
//

#import "MainTabBarViewController.h"
#import "CTabBar.h"

@interface MainTabBarViewController ()<CTabBarItemSelectedDelegate>
@property (nonatomic, strong) CTabBar *bottomView;
@end

@implementation MainTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self.tabBar setHidden:YES];
}

- (void)setTabBarHidden:(BOOL)tabBarHidden{
    [_bottomView setHidden:tabBarHidden];
}

- (void)CTabBar:(CTabBar *)tabbar selectedIndex:(NSInteger)index{
    [self setSelectedIndex:index];
}

- (void)addChildViewController:(UIViewController *)childController{
    [super addChildViewController:childController];
    [_bottomView addTabBar:childController.tabBarItem];
}

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
    [super tabBar:tabBar didSelectItem:item];
    NSInteger index = [self.tabBar.items indexOfObject:item];
    [_bottomView setSelectIndex:index];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
